require.config({
	paths: {
		"common": "common/common"
	}
	// baseUrl: 'js/common'
});

require(['common', 'dept'], function(defaultStr, queryData) {
	var baseUrl = defaultStr();
	var month = new Vue({
		el: '#login-container',
		data: {
			url: {
				'login': baseUrl + '/usr/user/login.do'
			},
			user: ''
		},
		methods: {
			login: function() {
				console.log('test');
				var _self = this;
				// _self.user.pwd = md5(_self.user.pwd);
				$.ajax({
					type: "POST",
					url: _self.url.login,
					data: JSON.stringify(_self.user),
					contentType: "application/json; charset=utf-8",
					dataType: 'json',
					success: function(result) {
						if (result.status == 1) {
							_self.setCookie('userName', result.body.loginName, 30);
							_self.setCookie('role', result.body.role, 30);

							// document.cookie = document.cookie + ';role' + '=' + result.body.role;
							window.location.replace("./index.html");
						} else {
							alert(result.message);
						}

					}
				});
			},
			setCookie: function(c_name, value, expiredays) {
				var exdate = new Date()
				exdate.setDate(exdate.getDate() + expiredays)
				document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString())
			}
		}
	})
})